<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>

<script src="${ctx}/includes/jquery.js" type="text/javascript"></script>
<script src="${ctx}/includes/jquery.form.js" type="text/javascript"></script>
<script src="${ctx}/includes/jquery.validate.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="${ctx}/style/form_table.css">
<script src="${ctx}/js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script>
$(function(){
	$("#edit_taskProcess_form").validate({
		errorPlacement: function(error, element){
            $(element).next('.field_notice').hide();
            $(element).after(error);
       },
	   success: function(label){   
	       label.addClass('right').text('OK!');
	   },
	   rules:   
	   {
	    	hanldresult : {required : true${taskstate == 1?',minlength:1':''}}
	   },   
	   message:{
	    	hanldresult : {required : '请输入处理结果',minlength:'请输入10个字以上的内容'}
	   }
	});  
});
</script>
<s:form id="edit_taskProcess_form" name="edit_taskProcess_form" method="post" action="taskProcess/update.do" enctype="multipart/form-data" onsubmit="return false;">
	<s:token/>
	<s:hidden id="taskid" name="taskid" />
	<s:hidden id="tpid" name="tpid" />
	<s:hidden id="creater" name="creater" />
	<table class="form-table">
		<tr>
			<th width="150">编号：</th>
			<td>${serial }</td>
		</tr>
		<tr>
			<th width="150">任务时间：</th>
			<td>
			${creattimeString }
			</td>
		</tr>
		<c:if test="${taskstate == 0 or taskstate == 2}">
		<tr>
			<th width="150">主题：</th>
			<td>
				<c:if test="${taskstate == 0 or taskstate == 2}">
				<s:textfield key="title" title="请填写业联标题" cssClass="form-txtinput" id="title" size="50" maxlength="100" value="%{model.title}"/>
				</c:if>
				<c:if test="${taskstate == 1}">
					${title }
				</c:if>
			</td>
		</tr>
		<tr>
			<th width="150">任务类别：</th>
			<td>
				<mytag:select id="lb" title="请选择业联类别" name="lb" sql="basedata" isSql="false" condition="27" dataType="Long" listKey="id" listValue="name" value="%{model.lb}" headerKey="" headerValue="请选择"/>
			</td>
		</tr>
		<tr>
			<th width="150">完成时间：</th>
			<td>
			<s:textfield id="jhwcsj" name="jhwcsj" title="请输入完成时间" cssClass="form-txtinput" maxlength="20" value="%{model.jhwcsjString}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="true"/>
			</td>
		</tr>
		<tr>
			<th width="150">任务内容：</th>
			<td>
				<textarea rows="35" name="content" title="请输入业联内容" id="content" style="width: 500px;height: 150px;">${content}</textarea>
			</td>
		</tr>
		<tr>
			<th width="150">主送部门：</th>
			<td>
				<select multiple="multiple" size="1" id="depts" title="请选择主送部门" name="deptids" style="width: 120px;;border:1px solid #DAE0E5;">
				<c:forEach items="${taskdepts}" var="item1" varStatus="status2">
				<option value="${item1.deptid }" selected="selected">${item1.orgInfo}</option>
				</c:forEach>
				</select>
				<span>
				<a class="btn_short" href="javascript:void(0)" title="添加部门" name="btn_addDepts" id="btn_Depts"
					onClick="selectDept()">选择</a>
				<a class="btn_short" href="javascript:void(0)" title="删除部门" name="btn_delDepts" id="btn_delDepts" 
				    onClick="deleteDept('depts');">删除</a>
				</span>
			</td>
		</tr>
		<tr>
			<th width="150">主送部门联系人：</th>
			<td>
			<s:textfield id="zsbmlxr" name="zsbmlxr" title="请输入主送部门联系人" cssClass="form-txtinput" maxlength="20" value="%{model.zsbmlxr}" />
			</td>
		</tr>
		<tr>
			<th width="150">抄送部门：</th>
			<td>
				<select multiple="multiple" size="4" id="senddepts" title="请选择抄送部门" name="sendDeptids" style="width: 120px;;border:1px solid #DAE0E5;height:120px;">
				<c:forEach items="${taskSendDepts}" var="item2" varStatus="status2">
				<option value="${item2.deptid }" selected="selected">${item2.orgInfo}</option>
				</c:forEach>
				</select>
				<span>
				<a class="btn_short" href="javascript:void(0)" title="添加部门" name="btn_addDepts" id="btn_Depts"
					onClick="selectSendDept()">选择</a>
				<a class="btn_short" href="javascript:void(0)" title="删除部门" name="btn_delDepts" id="btn_delDepts" 
				    onClick="deleteDept('senddepts');">删除</a>
				</span>
			</td>
		</tr>
		</c:if>
		<c:if test="${taskstate == 1}">
		<tr>
			<th width="150">主题：</th>
			<td>${title }</td>
		</tr>
		<tr>
			<th width="150">任务类别：</th>
			<td>${dataname }</td>
		</tr>
		<tr>
			<th width="150">完成时间：</th>
			<td>
			${jhwcsjString }
			</td>
		</tr>
		<tr>
			<th width="150">任务内容：</th>
			<td>${content}</td>
		</tr>
		<tr>
			<th width="150">主送部门：</th>
			<td>
				<c:forEach items="${taskdepts}" var="item1" varStatus="status2">
				${item1.orgInfo},
				</c:forEach>
			</td>
		</tr>
		<tr>
			<th width="150">主送部门联系人：</th>
			<td>${zsbmlxr }</td>
		</tr>
		<tr>
			<th width="150">抄送部门：</th>
			<td>
				<c:forEach items="${taskSendDepts}" var="item2" varStatus="status2">
				${item2.orgInfo},
				</c:forEach>
			</td>
		</tr>
		</c:if>
		<tr>
			<th width="150">审批状态：</th>
			<td>
				<c:if test="${taskstate == 0}">审批中</c:if>
				<c:if test="${taskstate == 1}">完成</c:if>
				<c:if test="${taskstate == 2}">退回</c:if>
			</td>
		</tr>
		<tr>
			<th width="150">执行状态：</th>
			<td>
				<c:if test="${execstate == -1}">未执行</c:if>
				<c:if test="${execstate == 0}">执行中</c:if>
				<c:if test="${execstate == 1}">完成</c:if>
				<c:if test="${execstate == 2}">终止</c:if>
			</td>
		</tr>
		<c:if test="${sessionScope.loginInfo.topdeptid == 9}">
		<c:if test="${execstate == 1}">
		<tr>
			<th width="150">查看详情：</th>
			<td>
				<a href="${ctx}/task_print.do?taskid=${taskid}" target="_blank">查看业务联系书</a>
			</td>
		</tr>
		</c:if>
		</c:if>
	</table>
	<table class="form-table">
		<tr>
			<th colspan="8" style="text-align: left;">办理意见</th>
		</tr>
		<tr>
			<th width="50" style="text-align: center;">序号</th>
			<th width="10%" style="text-align: center;">办理人编号</th>
			<th width="10%" style="text-align: center;">办理人</th>
			<th width="10%" style="text-align: center;">上一办理人</th>
			<%--<th width="10%" style="text-align: center;">操作类型</th> --%>
			<th width="10%" style="text-align: center;">办理类型</th>
			<th width="10%" style="text-align: center;">处理状态</th>
			<th width="20%" style="text-align: center;">办理时间</th>
			<th style="text-align: center;">办理结果</th>
		</tr>
		<c:forEach items="${taskProcessList}" var="item" varStatus="status">
		<tr>
			<td align="center">${status.index+1}</td>
			<td align="center">${item.hanlder }</td>
			<td align="center">${item.username }</td>
			<td align="center">${item.zprxm }</td>
			<%--<td align="center">
				<c:if test="${item.opttype == -1}">退回</c:if>
				<c:if test="${item.opttype == 1}">审批</c:if>
				<c:if test="${item.opttype == 2}">执行</c:if>
				<c:if test="${item.opttype == 3}">抄送</c:if>
			</td>--%>
			<td align="center">
				<c:if test="${item.hanldetype == 1}">办理</c:if>
				<c:if test="${item.hanldetype == 2}"><span style="color: blue;">抄送</span></c:if>
				<c:if test="${item.hanldetype == 3}">代办</c:if>
				<c:if test="${item.hanldetype == 4}">转下一审批</c:if>
				<c:if test="${item.hanldetype == 5}">审批完成</c:if>
				<c:if test="${item.hanldetype == 6}">审批退回</c:if>
			</td>
			
			<td align="center">
				<c:if test="${item.hanldestate == 0}">未处理</c:if>
				<c:if test="${item.hanldestate == 1}">完成</c:if>
			</td>
			
			<td align="center">${item.hanldtimeString}</td>
			<td align="left">${item.hanldresult}</td>
		</tr>
		</c:forEach>
	</table>
	<table class="form-table">
		<tr>
			<th colspan="5" style="text-align: left;">附件信息</th>
		</tr>
		<tr>
			<th width="50" style="text-align: center;">序号</th>
			<th style="text-align: center;">文件名称</th>
			<th style="text-align: center;">上传者</th>
			<th style="text-align: center;">大小</th>
			<th style="text-align: center;">上传时间</th>
		</tr>
		<c:forEach items="${attach}" var="item" varStatus="status">
		<tr>
			<td align="center">${status.index+1}</td>
			<td align="left"><a href="javascript:;" onclick="downloadFile('${item.attachid}');">${item.name }</a></td>
			<td align="center">${item.username }</td>
			<td align="center">${item.filesize}</td>
			<td align="center">${item.upTimeString}</td>
		</tr>
		</c:forEach>
	</table>
	<table class="form-table">
		<c:if test="${taskstate == 0}">
		<tr>
			<th width="150"><span class="note_red">*</span>办理意见：</th>
			<td>
				<select name="hanldresult" id="hanldresult" onchange="xzblyj(this)">
					<option value="">请选择</option>
					<option value="同意">同意</option>
					<option value="退回">退回</option>
				</select>
			</td>
		</tr>
		</c:if>
		<c:if test="${taskstate == 1}">
			<c:if test="${tp.taskaction == -2 or tp.taskaction == -1 or tp.taskaction == 0 or tp.taskaction == 2 }">
			<tr>
				<th width="150"><span class="note_red">*</span>办理结果：</th>
				<td>
				<textarea rows="4" name="hanldresult" id="hanldresult" style="width: 500px;"></textarea>
				</td>
			</tr>
			</c:if>
			<c:if test="${tp.taskaction == 1}">
			<tr>
				<th width="150"><span class="note_red">*</span>办理意见：</th>
				<td>
				<select name="hanldresult" id="hanldresult">
					<option value="">请选择</option>
					<option value="同意">同意</option>
					<option value="退回">退回</option>
				</select>
				</td>
			</tr>
			<tr>
				<th width="150"><span class="note_red">*</span>办理结果：</th>
				<td>
				<textarea rows="4" name="optHanldresult" id="optHanldresult" style="width: 500px;"></textarea>
				</td>
			</tr>
			</c:if>
			<c:if test="${tp.taskaction == 3}">
			<th width="150"><span class="note_red">*</span>办理结果：</th>
				<td>
				<textarea rows="4" name="hanldresult" id="optHanldresult" style="width: 500px;" readonly="true">已知晓</textarea>
				</td>
			</tr>
			</c:if>
		</c:if>
		<c:if test="${taskstate == 2}">
		<tr>
			<th width="150"><span class="note_red">*</span>办理结果：</th>
			<td>
			<textarea rows="4" name="hanldresult" id="hanldresult" style="width: 500px;"></textarea>
			</td>
		</tr>
		</c:if>
		<tr>
			<th width="150">附件：</th>
			<td id="files">
			<input type="button" onclick="addComponent();" value="添加文件" /> <br/>
			<input name="attachFiles" type="file" size="50"/>
			</td>
		</tr>
		<c:if test="${taskstate == 0}">
			<tr>
				<th width="150">审批人：</th>
				<td>
				<s:hidden name="hanlder" id="zrrbh"/>
				<s:textfield name="zrr" title="请选择人员" cssClass="form-txtinput" id="shzrr" maxlength="20" value=""/>
				
				<label>如果不需要转下一审批，可直接点击“审核完成”</label>
				</td>
			</tr>
		</c:if>
		<c:if test="${taskstate == 1}">
			<c:if test="${tp.taskaction == -1 or tp.taskaction == -2 or tp.taskaction == 1}">
				<c:if test="${tp.taskaction == -2 or tp.taskaction == -1}">
				<tr>
					<th width="150">操作类型：</th>
					<td>
						<input type="radio" name="optAction" value="1" checked="checked" onclick="wsZxCz(1)"/>审核
						<input type="radio" name="optAction" value="2" onClick="wsZxCz(2)"/>分配执行
					</td>
				</tr>
				<tr style="display: none;" id="ws_zx_zxr">
					<th width="150">负责人：</th>
					<td>
					<select multiple="multiple" size="4" id="users" title="请选择执行人员" name="execUsers" style="width: 120px;;border:1px solid #DAE0E5;height:100px;"></select>
					<span style="height: auto">
					<a class="btn_short" href="javascript:void(0)" title="添加用户" name="btn_addAttendUsers" id="btn_attendUsers"
						onClick="selectUser()">选择</a>
					<a class="btn_short" href="javascript:void(0)" title="删除用户" name="btn_delAttendUsers" id="btn_delAttendUsers" 
					    onClick="deleteUser();">删除</a>
					</span>
				</tr>
				<tr id="ws_zx_sh">
					<th width="150">审核人：</th>
					<td>
					<s:hidden name="hanlder" id="zrrbh"/>
					<s:textfield name="zrr" title="请选择人员" cssClass="form-txtinput" id="zrr" maxlength="20" value="%{model.hander}"/>
					</td>
				</tr>
				</c:if>
			</c:if>
			
			<c:if test="${tp.taskaction == 0}">
			<tr>
				<th width="150">负责人：</th>
				<td>
					<%--
					<s:hidden name="hanlder" id="zrrbh"/>
					<s:textfield name="zrr" title="请选择人员" cssClass="form-txtinput" id="zrr" maxlength="20" value="%{model.hander}"/>
					--%>
					<select multiple="multiple" size="4" id="users" title="请选择执行人员" name="execUsers" style="width: 120px;;border:1px solid #DAE0E5;height:120px;"></select>
					<span style="height: auto">
					<a class="btn_short" href="javascript:void(0)" title="添加用户" name="btn_addAttendUsers" id="btn_attendUsers"
						onClick="selectUser()">选择</a>
					<a class="btn_short" href="javascript:void(0)" title="删除用户" name="btn_delAttendUsers" id="btn_delAttendUsers" 
					    onClick="deleteUser();">删除</a>
					</span>
					<label style="color: red;">如果不需要转其它人处理，请直接点击“提交完成”</label>
					
				</td>
			</tr>
			</c:if>
			
			<c:if test="${tp.taskaction == 1}">
			<tr>
				<th width="150">负责人：</th>
				<td>
				<select multiple="multiple" size="4" id="users" title="请选择执行人员" name="execUsers" style="width: 120px;;border:1px solid #DAE0E5;height:120px;"></select>
				<span style="height: auto">
				<a class="btn_short" href="javascript:void(0)" title="添加用户" name="btn_addAttendUsers" id="btn_attendUsers"
					onClick="selectUser()">选择</a>
				<a class="btn_short" href="javascript:void(0)" title="删除用户" name="btn_delAttendUsers" id="btn_delAttendUsers" 
				    onClick="deleteUser();">删除</a>
				</span>
			</tr>
			</c:if>
			
			<c:if test="${tp.taskaction == 3}">
			<tr>
				<th width="150">查阅人：</th>
				<td>
				<select multiple="multiple" size="4" id="users" title="请选择人员" name="execUsers" style="width: 120px;;border:1px solid #DAE0E5;height:120px;"></select>
				<span style="height: auto">
				<a class="btn_short" href="javascript:void(0)" title="添加用户" name="btn_addAttendUsers" id="btn_attendUsers"
					onClick="selectUser()">选择</a>
				<a class="btn_short" href="javascript:void(0)" title="删除用户" name="btn_delAttendUsers" id="btn_delAttendUsers" 
				    onClick="deleteUser();">删除</a>
				</span>
				<label style="color: red;">如果不需要转其它人查阅人，请直接点击“提交完成”</label>
			</tr>
			</c:if>
		</c:if>
		
		<c:if test="${taskstate == 2}">
			<th width="150">审核人：</th>
			<td>
			<input type="hidden" name="hanlder" value="${thr }"/>
			<s:textfield name="zrr" title="请选择审核人" cssClass="form-txtinput" id="zrr" readonly="true" maxlength="20" value="%{model.thrxm}"/>
			</td>
		</c:if>
	</table>
	<div class="win-btn-panel" style="text-align: center;margin-top: 5px;">
		<c:if test="${taskstate == 0}">
			<input class="btn-short" type="button" name="subbtn" id="zxysp" value="转下一审批" title="点击提交" onClick="zxyspTask();"/>
			<input class="btn-short" type="button" name="subbtn" id="spwc" value="审批完成" title="点击提交" onClick="spwcTask();"/>
		</c:if>
		<c:if test="${taskstate == 1}">
			<c:if test="${execstate == -1}">
			<input class="btn-short" type="button" name="subbtn" id="fpzx" value="分配执行" title="点击提交" onClick="zxfpTask();"/>
			</c:if>
			<c:if test="${execstate == 0}">
				<c:if test="${tp.taskaction == -1}">
				<input  style="display: none;" class="btn-short" type="button" name="subbtn" id="zxfp" value="执行分配" title="点击提交" onClick="zxfpTask();"/>
				<input class="btn-short" type="button" name="subbtn" id="tjsh" value="提交审核" title="点击提交" onClick="tjshTask();"/>
				</c:if>
				<c:if test="${tp.taskaction == -2}">
				<input class="btn-short" type="button" name="subbtn" id="ztr" value="执行分配" title="点击提交" onClick="zxfpTask();"/>
				</c:if>
				<c:if test="${tp.taskaction == 1}">
				<input class="btn-short" type="button" name="subbtn" id="shwc" value="审核完成" title="点击提交" onClick="shTask();"/>
				</c:if>
				<c:if test="${tp.taskaction == 0}">
				<input class="btn-short" type="button" name="subbtn" id="ztr" value="转他人" title="点击提交" onClick="zxztrTask();"/>
				<input class="btn-short" type="button" name="subbtn" id="tjwc" value="提交完成" title="点击提交" onClick="zxclTask();"/>
				</c:if>
				
				<c:if test="${tp.taskaction == 2}">
				<input class="btn-short" type="button" name="subbtn" id="gbwc" value="关闭完成任务" title="点击提交" onClick="closeTask();"/>
				</c:if>
				
			</c:if>
			<c:if test="${execstate == 1}">
				<c:if test="${tp.taskaction == 3}">
				<input class="btn-short" type="button" name="subbtn" id="tjrw" value="提交完成" title="点击提交" onClick="tjrwTask();"/>
				</c:if>
			</c:if>
		</c:if>
		<c:if test="${taskstate == 2}">
			<input class="btn-short" type="button" name="subbtn" id="zxysp" value="提交审核" title="点击提交" onClick="tjspTask();"/>
		</c:if>
	</div>
</s:form>
<script type="text/javascript">
//var api = frameElement.api, W = api.opener;
function addComponent(){
	var tid = new Date().getTime();
	var str = "<div id='"+tid+"'><input type='file' name='attachFiles'  size='50'/><input type='button' value='删除' onclick='delUpFile("+tid+")'/></div>";
	$('#files').append(str);
}
function delUpFile(tid){
	$('#'+tid).remove();
}
$('#zrr').click(function(){
	parent.$.dialog({
	  	id:'abc', 
	  	title:'选择人员', 
	  	content: 'url:${ctx}/pub/userAllByDeptSelect.jsp?timestamp='+new Date().getTime(), 
	  	max:false,
	  	min:false,
	  	width:600, 
	  	height:450,
	  	ok: function(){ 
	       	var m = parent.abc.selectOnlyUserByTask();
	        return m; 
	    }, 
	    cancelVal: '关闭', 
	    cancel: true
  	});
});
$('#shzrr').click(function(){
	parent.$.dialog({
	  	id:'abc', 
	  	title:'选择人员', 
	  	content: 'url:${ctx}/pub/userAllByAllDeptSelect.jsp?timestamp='+new Date().getTime(), 
	  	max:false,
	  	min:false,
	  	width:600, 
	  	height:450,
	  	ok: function(){ 
	       	var m = parent.abc.selectOnlyUserByTask();
	        return m; 
	    }, 
	    cancelVal: '关闭', 
	    cancel: true
  	});
});
function selectUser(){
  parent.$.dialog({
  	id:'abc', 
  	name:'abc',
  	title:'选择人员', 
  	content: 'url:${ctx}/pub/userAllByDeptSelect.jsp?timestamp='+new Date().getTime(), 
  	max:false,
  	min:false,
  	width:600, 
  	height:450,
  	ok: function(){ 
       	var m = parent.abc.selectMoreUserByTask();
        return m; 
    }, 
    cancelVal: '关闭', 
    cancel: true
  });
}
function deleteUser(){
	var selectObj = document.getElementById("users");
	var selectOptions = selectObj.options;
	if (selectOptions == null || selectOptions.length == 0 || selectOptions.selectedIndex == -1){
		var msg="请先选择要删除的人员！";
		alert(msg);
		return;
	}
	var ilen=selectOptions.length;
	for (var i=ilen-1; i>=0; i--){
		if(selectObj[i].selected)
		    selectObj.remove(i);
	}
}
/*转下一审批人*/
function zxyspTask(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	var zrr = $('#shzrr').val();
	if(zrr == ''){alert('请选择审批人!');return false;}
	
	if(checkform()){
	$('#edit_taskProcess_form').attr("action","task_zxyspTask.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
	}
    return false;
    
}

/*转下一审批人*/
function tjspTask(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	
	var title = $('#title').val();
	if(title == ''){alert('请填写主题!');return false;}
	
	var lb = $('#lb').val();
	if(lb == ''){alert('请选择类别!');return false;}
	
	var jhwcsj = $('#jhwcsj').val();
	if(jhwcsj == ''){alert('请填写计划完成时间!');return false;}
	
	var content = $('#content').val();
	if(content == ''){alert('请填写内容!');return false;}
	
	var selectObj = document.getElementById("depts");
	var selectOptions = selectObj.options;
	if (selectOptions == null || selectOptions.length == 0){
		alert('请填写主送部门!');return false;
	}else{
		for (var i=0;i<selectOptions.length;i++){
			selectObj[i].selected = true;
		}
	}
	
	var selectObj2 = document.getElementById("senddepts");
	var selectOptions2 = selectObj2.options;
	if (selectOptions2 == null || selectOptions2.length == 0){
		
	}else{
		for (var i=0;i<selectOptions2.length;i++){
			selectObj2[i].selected = true;
		}
	}
	
	var zrr = $('#zrr').val();
	if(zrr == ''){alert('请选择审批人!');return false;}
	
	$('#edit_taskProcess_form').attr("action","task_tjspTask.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
    return false;
    
}
/*审批完成*/
function spwcTask(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	var creater = $('#creater').val();
	$('#zrrbh').val(creater);
	
	if(checkform()){
	$('#edit_taskProcess_form').attr("action","task_spwcTask.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
	}
    return false;
    
}
/*提交审核任务*/
function tjshTask(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	var zrr = $('#zrr').val();
	if(zrr == ''){alert('请选择负责人!');return false;}
	
	
	$('#edit_taskProcess_form').attr("action","task_tjshTask.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
    return false;
}
/*审核任务*/
function shTask(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	
	var ohr = $('#optHanldresult').val();
	if(ohr == ''){alert('请填写办理结果!');return false;}
	
	if($('#hanldresult').val() == "同意"){
		//var zrr = $('#zrr').val();
		//if(zrr == ''){alert('请选择负责人!');return false;}
		var selectObj = document.getElementById("users");
		var selectOptions = selectObj.options;
		if (selectOptions == null || selectOptions.length == 0){
			alert('请选择负责人');
			return;
		}
		if (selectOptions == null || selectOptions.length == 0){
			return;
		}else{
			for (var i=0;i<selectOptions.length;i++){
				selectObj[i].selected = true;
			}
		}
	}
	$('#edit_taskProcess_form').attr("action","task_shTask.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
    return false;
}
/*执行分配任务*/
function zxfpTask(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	//var zrr = $('#zrr').val();
	//if(zrr == ''){alert('请选择负责人!');return false;}
	
	var selectObj = document.getElementById("users");
	var selectOptions = selectObj.options;
	if (selectOptions == null || selectOptions.length == 0){
		alert('请选择执行人');
		return;
	}
	if (selectOptions == null || selectOptions.length == 0){
		return;
	}else{
		for (var i=0;i<selectOptions.length;i++){
			selectObj[i].selected = true;
		}
	}
	
	$('#edit_taskProcess_form').attr("action","task_zxfpTask.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
    return false;
	
}
/*执行转他人任务*/
function zxztrTask(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	/*
	var zrr = $('#zrr').val();
	if(zrr == ''){alert('请选择负责人!');return false;}
	*/
	var selectObj = document.getElementById("users");
	var selectOptions = selectObj.options;
	if (selectOptions == null || selectOptions.length == 0){
		alert('请选择人员');
		return;
	}
	if (selectOptions == null || selectOptions.length == 0){
		return;
	}else{
		for (var i=0;i<selectOptions.length;i++){
			selectObj[i].selected = true;
		}
	}
	
	$('#edit_taskProcess_form').attr("action","task_zxztrTask.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
    return false;
}
/*执行处理任务*/
function zxclTask(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	var creater = $('#creater').val();
	$('#zrrbh').val(creater);
	
	if(window.confirm('确定不需要转他人处理，"提交完成"任务吗？')){
		$('#edit_taskProcess_form').attr("action","task_zxclTask.do");
		$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
	}
    return false;
}

/*执行处理抄送任务*/
function tjrwTask(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	
	$('#edit_taskProcess_form').attr("action","task_tjrwTask.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
    return false;
}
/*关闭任务*/
function closeTask(){
	var v = $("#edit_taskProcess_form").valid();
	if(!v)return false;
	
	$('#edit_taskProcess_form').attr("action","task_closeTask.do");
	$('#edit_taskProcess_form').ajaxSubmit(resultHandler);
    return false;
}
function resultHandler(responseXML){
	var result = responseXML.getElementsByTagName("result")[0].firstChild.nodeValue;
	var message = responseXML.getElementsByTagName("error-message")[0].firstChild.nodeValue;
	var errorType = responseXML.getElementsByTagName("error-type")[0].firstChild.nodeValue;
	if(!eval(result)&&(errorType!=2)){
		alert(message);
	}
	else{
		var curDate = new Date(); 
		alert(message);
		parent.location.replace("${ctx}/task_myTask.do?opt=my&timsStamp=" + curDate.getTime());
	}
}
function downloadFile(A){
	window.location.href='${ctx}/filedownload.do?fileAsName='+A+'&timsStamp=' + new Date().getTime();
}
function wsZxCz(A){
	if(A == 1){
		$('#ws_zx_sh').removeAttr('style');
		$('#ws_zx_zxr').attr('style','display:none');
		
		$('#tjsh').removeAttr('style');
		$('#zxfp').attr('style','display:none');
	}else{
		
		$('#ws_zx_sh').attr('style','display:none');
		$('#ws_zx_zxr').removeAttr('style');
		
		$('#tjsh').attr('style','display:none');
		$('#zxfp').removeAttr('style');
	}
}
function xzblyj(A){
	if(A.value == '同意'){
		//$('#spwc').attr('style','display:none');
		$('#spwc').removeAttr('style');
		$('#zxysp').removeAttr('style');
		$('#spwc').val('审批完成');
	}else if(A.value == '退回'){
		$('#zxysp').attr('style','display:none');
		$('#spwc').removeAttr('style');
		$('#spwc').val('审批退回');
	}else{
		$('#spwc').removeAttr('style');
		$('#zxysp').removeAttr('style');
		$('#spwc').val('审批完成');
	}
}

function selectDept(){
  parent.$.dialog({
  	id:'abc', 
  	name:'abc',
  	title:'选择部门', 
  	content: 'url:${ctx}/pub/userAllTopDeptSelect.jsp?timestamp='+new Date().getTime(), 
  	max:false,
  	min:false,
  	width:600, 
  	height:450,
  	ok: function(){ 
       	var m = parent.abc.selectOneDeptByTask();
       	if(m){
        	return true; 
        }else{
        	return false;
        }
    }, 
    cancelVal: '关闭', 
    cancel: true
  });
}

function selectSendDept(){
  parent.$.dialog({
  	id:'abc', 
  	name:'abc',
  	title:'选择部门', 
  	content: 'url:${ctx}/pub/userAllTopDeptSelect.jsp?timestamp='+new Date().getTime(), 
  	max:false,
  	min:false,
  	width:600, 
  	height:450,
  	ok: function(){ 
       	var m = parent.abc.selectMoreSendDeptByTask();
       	return true;
    }, 
    cancelVal: '关闭', 
    cancel: true
  });
}

function deleteDept(A){
	var selectObj = document.getElementById(A);
	var selectOptions = selectObj.options;
	if (selectOptions == null || selectOptions.length == 0 || selectOptions.selectedIndex == -1){
		var msg="请先选择要删除的部门！";
		alert(msg);
		return;
	}
	var ilen=selectOptions.length;
	for (var i=ilen-1; i>=0; i--){
		if(selectObj[i].selected)
		    selectObj.remove(i);
	}
}

function checkform(){
	var title = $('#title').val();
	if(title == ''){alert('请填写主题!');return false;}
	
	var lb = $('#lb').val();
	if(lb == ''){alert('请选择类别!');return false;}
	
	var jhwcsj = $('#jhwcsj').val();
	if(jhwcsj == ''){alert('请填写计划完成时间!');return false;}
	
	var content = $('#content').val();
	if(content == ''){alert('请填写内容!');return false;}
	
	var selectObj = document.getElementById("depts");
	var selectOptions = selectObj.options;
	if (selectOptions == null || selectOptions.length == 0){
		alert('请填写主送部门!');return false;
	}else{
		for (var i=0;i<selectOptions.length;i++){
			selectObj[i].selected = true;
		}
	}
	
	var selectObj2 = document.getElementById("senddepts");
	var selectOptions2 = selectObj2.options;
	if (selectOptions2 == null || selectOptions2.length == 0){
		
	}else{
		for (var i=0;i<selectOptions2.length;i++){
			selectObj2[i].selected = true;
		}
	}
	return true;
}
</script>
</script>
